/*
 ============================================================================
 Name		: ResponseDispatcher.cpp
 Author	  : 
 Version	 : 1.0
 Copyright   :
 Description : CResponseDispatcher implementation
 ============================================================================
 */

#include "ResponseGroupbuyDetail.h"
#include "ResponseDefinses.h"
#include "ProjectsDefines.h"
#include "ResponseMagazineItemData.h"

CResponseGroupbuyDetail::CResponseGroupbuyDetail( )
{
    // No implementation required
}

CResponseGroupbuyDetail::~CResponseGroupbuyDetail( )
{
    SAFE_DELETE( _data );
}

CResponseGroupbuyDetail* CResponseGroupbuyDetail::NewLC( )
{
    CResponseGroupbuyDetail* self = new ( ELeave ) CResponseGroupbuyDetail( );
    CleanupStack::PushL( self );
    self->ConstructL( );
    return self;
}

CResponseGroupbuyDetail* CResponseGroupbuyDetail::NewL( )
{
    CResponseGroupbuyDetail* self = CResponseGroupbuyDetail::NewLC( );
    CleanupStack::Pop( ); // self;
    return self;
}

void CResponseGroupbuyDetail::ConstructL( )
{
    
}

void CResponseGroupbuyDetail::LoadValidResponseFromXmlNode( CElement* elementResponse )
{
    _ASSERT_LOG( elementResponse != NULL );

    if( !elementResponse )
    {
        return;
    }

    CElement* elemetnResult = elementResponse->GetElement( kResponseResultNode );
    _ASSERT_LOG( elemetnResult );

    if( !elemetnResult )
    {
        return;
    }
    _LIT( kResponseInfoNode , "info");
    CElement* elementInfo = elemetnResult->GetElement( kResponseInfoNode );
    if( elementInfo )
    {
        _data = ResponseMagazineItemDataParser::Parse( elementInfo );
    }
    else
    {
        _data = ResponseMagazineItemDataParser::Parse( elemetnResult );
    }
    //
    //int count = elemetnResult->ElementCount( );
    //for( int index = 0; index < count; index++ )
    //{
    //    CElement* element = elemetnResult->GetElement( index );
    //_LIT( kResponseDipathcerItemNode, "items" );
    //    if( element && element->GetName( ) == kResponseInfoNode )
    //     {
    // _data = ResponseMagazineItemDataParser::Parse( elemetnResult );
    //     }
    //  }
}
